﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperMap.Data;


namespace DTGroup.iNek.WinUI
{
    /// <summary>
    /// 坐标投影转换类
    /// </summary>
    public class CoordSysProjectionTranslator:BaseGisHandler<CoordSysProjectionTranslator>
    {
        /// <summary>
        /// 地图一致的投影转换为WGS84 即经纬度投影的坐标
        /// </summary>
        /// <param name="point">GeoPoint</param>
        /// <param name="sourcePrjCoordSys">GeoPoint的投影</param>
        /// <param name="targetPrjCoordSys">GeoPoint的目标投影</param>
        public void ConvertCoordSysPrjCoordSys(GeoPoint point, PrjCoordSys sourcePrjCoordSys, PrjCoordSys targetPrjCoordSys)
        {
            CoordSysTranslator.Convert(point, sourcePrjCoordSys, targetPrjCoordSys, new CoordSysTransParameter(), CoordSysTransMethod.CoordinateFrame);
        }
        /// <summary>
        /// 投影转换
        /// </summary>
        /// <param name="region">GeoRegion</param>
        /// <param name="sourcePrjCoordSys">GeoRegion的投影</param>
        /// <param name="targetPrjCoordSys">GeoRegion的目标投影</param>
        public void ConvertCoordSysPrjCoordSys(GeoRegion region, PrjCoordSys sourcePrjCoordSys, PrjCoordSys targetPrjCoordSys)
        {
            CoordSysTranslator.Convert(region, sourcePrjCoordSys, targetPrjCoordSys, new CoordSysTransParameter(), CoordSysTransMethod.CoordinateFrame);
        }

        /// <summary>
        /// 地图一致的投影转换为WGS84 即经纬度投影的坐标（此数据集必须存在自己的投影、目前只支持矢量数据集）
        /// </summary>
        /// <param name="dataset">Dataset</param>
        /// <param name="targetPrjCoordSys">Dataset的目标投影</param>
        public void ConvertCoordSysPrjCoordSys(Dataset dataset, PrjCoordSys targetPrjCoordSys)
        {
            CoordSysTranslator.Convert(dataset, targetPrjCoordSys, new CoordSysTransParameter(), CoordSysTransMethod.CoordinateFrame);
        }

        /// <summary>
        /// 地图一致的投影转换为WGS84 即经纬度投影的坐标（此数据集必须存在自己的投影）
        /// </summary>
        /// <param name="dataset">Dataset</param>
        /// <param name="targetPrjCoordSys">Dataset的目标投影</param>
        /// <param name="targetDatasetName">目标数据集名称</param>
        /// <param name="targetDatasetSource">目标数据源</param>
        public void ConvertCoordSysPrjCoordSys(Dataset dataset, Datasource targetDatasetSource, PrjCoordSys targetPrjCoordSys, string targetDatasetName)
        {
            if (targetDatasetSource.Datasets.Contains(targetDatasetName))
            {
                targetDatasetSource.Datasets.Delete(targetDatasetName);
            }

            CoordSysTranslator.Convert(dataset, targetPrjCoordSys, targetDatasetSource, targetDatasetName, new CoordSysTransParameter(), CoordSysTransMethod.CoordinateFrame);
        }

        /// <summary>
        /// 投影转换
        /// </summary>
        /// <param name="geometry">Geometry</param>
        /// <param name="sourcePrjCoordSys">Geometry的投影</param>
        /// <param name="targetPrjCoordSys">Geometry的目标投影</param>
        public void ConvertCoordSysPrjCoordSys(Geometry geometry, PrjCoordSys sourcePrjCoordSys, PrjCoordSys targetPrjCoordSys)
        {
            CoordSysTranslator.Convert(geometry, sourcePrjCoordSys, targetPrjCoordSys, new CoordSysTransParameter(), CoordSysTransMethod.CoordinateFrame);
        }
    }
}
